Skip to content

fix: preserve taxonomy subterm depth per root - #2971

Open
RabbiIslamRony wants to merge 2 commits into
developmentfrom
investigate-client-issue-3243
Open

fix: preserve taxonomy subterm depth per root#2971
RabbiIslamRony wants to merge 2 commits into
developmentfrom
investigate-client-issue-3243

Conversation

@RabbiIslamRony

Copy link
Copy Markdown
Member

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Security fix
  • Improvement
  • New Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Text changes
  • Other... Please describe:

Description

Main issue

The All Locations and All Categories list views used one shared $this->depth value while rendering every top-level taxonomy term. subterms_html() reduced that property during recursion and never restored it.

As a result, earlier roots consumed the configured depth. Later roots could still have has_child = true, so the template displayed a dropdown arrow, but their subterm_html was empty. Clicking those dropdowns only toggled a CSS class because no child <ul> had been rendered.

The reported location order reproduced the problem clearly with depth 2:

  1. USA rendered its children and reduced the shared depth to 1.
  2. South Africa rendered its children and reduced the shared depth to 0.
  3. Australia and Africa still had children but rendered no child list.

Fix

The remaining depth is now passed by value to each recursive call. The configured $this->depth property is left unchanged, so every top-level root gets the same depth budget while deeper terms still respect the configured limit.

A dependency-free regression test was added because this repository does not currently include a PHPUnit test suite.

How to reproduce and test

  1. Create four top-level locations in this order: USA, South Africa, Australia, and Africa.
  2. Add at least one child under every top-level location and set the location depth to 2.
  3. Before this change, only the earlier roots render dropdown content; Australia and Africa show arrows but do not open.
  4. Run php tests/php/listing-taxonomy-subterms.php.
  5. Confirm the command prints PASS: taxonomy subterm depth is isolated per root.
  6. Confirm every top-level location renders its child list and terms deeper than the configured depth remain hidden.

Any linked issues

Checklist

@RabbiIslamRony
RabbiIslamRony changed the base branch from trunk to development August 24, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant